<template>
	<view class="content">
		<downloadPop :file_path="file_path"></downloadPop>
		<view class="section-0">
			<view class="section-body">
				<view class="item" v-for="item in list" :key="item.id">
					<view class="title">{{item.name}}</view>
					<view class="name" v-if="!item.isTextArea">
						<view @click="handleDownLoad(item.name,item.content)" :class="`name-text ${item.isFile ? 'name-text__file': ''}`">
							{{item.content}}
						</view>
						<!-- <view class="action" v-if="!item.isTextArea">
							<view :class="`check ${checkList.indexOf(item.id) !== -1 ? 'check__active' : ''}`"
								@click="handleCheck(item.id)">
								<view class="iconfont icon-duigou"></view>
							</view>
						</view> -->
					</view>
					<view class="textarea" v-if="item.isTextArea">
						<u--textarea :maxlength="-1" placeholderClass="textarea-placeholder" class="textarea-body"
							placeholder="输入备注内容..." v-model="memo" border='null'></u--textarea>
					</view>
				</view>
				<!-- <view class="custom-button" @click="submit()">发送报错</view> -->
			</view>
		</view>
	</view>
</template>

<script>
	import {
		reportApi
	} from '@/api/project_manage.js'
	import {
		krpsApi, xmhApi, yearPlanApi
	} from '@/api/center.js'
	import {
		mapGetters
	} from 'vuex'
	import downloadPop from '@/components/download_pop/index.vue';
	export default {
		components: { downloadPop },
		data() {
			return {
				file_path: '',
				type: 1,
				list: [
					{
						id: 2,
						name: '文件编号',
						content: ''
					},
					{
						id: 3,
						name: '发文时间',
						content: ''
					},
					{
						id: 4,
						name: '总估算',
						content: ''
					},
					{
						id: 5,
						name: '附件',
						content: '',
						isFile: true
					},
				],
				checkList: [],
				memo: ''
			}
		},
		computed: {
			...mapGetters({
				curProject: 'system/getCurProject'
			})
		},
		methods: {
			handleDownLoad(name,url){
				if(name=='附件'){
					this.file_path = '';
					setTimeout(() => {
						this.file_path = url;
					}, 0);
				}
			},
			handleCheck(id) {
				const idx = this.checkList.indexOf(id);
				if (idx === -1) {
					this.checkList.push(id);
				} else {
					this.checkList.splice(idx, 1);
				}
			}
		},
		async onReady() {
			// console.log(this.type)
			if (this.type == 1) {
				krpsApi({project_id: this.curProject.id}).then(obj => {
					let data = obj.data.data;
					data=data.data[0]|| {}
					// this.list[0].content = data.file_name || '-';
					this.list[0].content = data.file_no ? data.file_no: '-';
					this.list[1].content = data.project_kyps_time ? data.project_kyps_time.substring(0, 10) : '-';
					this.list[2].content = data.total_sum ? data.total_sum: '-';
					this.list[3].content = data.file_path ? data.file_path: '-';
				});
			}
			if (this.type == 2) {
				xmhApi({project_id: this.curProject.id}).then(obj => {
					let data = obj.data.data;
					data = data.data[0] || {}
					// this.list[0].content = data.file_name || '-';
					this.list[0].content = data.file_no ? data.file_no: '-';
					this.list[1].content = data.project_xmhz_time ? data.project_xmhz_time.substring(0, 10) : '-';
					// this.list[2].content = data.total_sum || '-';
					this.list[2].content = data.file_path ? data.file_path: '-';
				});
			}
			if (this.type == 3) {
				yearPlanApi({project_id: this.curProject.id}).then(obj => {
					this.list[0].content = obj.data.data.start_time=' '|null?'-':obj.data.data.start_time.split(' ')[0];
					this.list[1].content = obj.data.data.put_time=' '|null?'-':obj.data.data.put_time.split(' ')[0];
			
				});
			}
		},
		onLoad(params) {
			this.type = params.type;
			switch (this.type) {
				case '1':
					uni.setNavigationBarTitle({
						title: '可研批复'
					});
					break;
				case '2':
					uni.setNavigationBarTitle({
						title: '核准批复'
					});
					this.list = [{
							id: 1,
							name: '文件编号',
							content: '-'
						},{
							id: 2,
							name: '发文时间',
							content: '-'
						},{
							id: 3,
						    name: '附件',
						    content: '',
						    isFile: true
						},
						]
					break;
				case '3':
					uni.setNavigationBarTitle({
						title: '核对年度计划'
					});
					this.list = [{
							id: 1,
							name: '里程碑开工时间',
							content: '-'
						},
						{
							id: 2,
							name: '里程碑投产时间',
							content: '-'
						},
						{
							id: 3,
							name: '内控开工时间',
							content: '-'
						},
						{
							id: 4,
							name: '内控投产时间',
							content: '-'
						},
						{
							id: 5,
							name: '实际开工时间',
							content: '-'
						},
						{
							id: 6,
							name: '实际投产时间',
							content: '-'
						},
					]
					break;
				case '4':
					uni.setNavigationBarTitle({
						title: '可研设计和评审进度'
					});
					this.list = [{
							id: 1,
							name: '可研设计单位',
							content: '-'
						},
						{
							id: 2,
							name: '可研报告交付时间',
							content: '-'
						},
						{
							id: 3,
							name: '可研评审时间',
							content: '-'
						},
						{
							id: 4,
							name: '备注',
							isTextArea: true
						},
					]
					break;
				default:
					uni.setNavigationBarTitle({
						title: '可研批复'
					});
					break;
			}
		}
	}
</script>

<style lang="scss" scoped>
	.custom-button {
		margin-top: 70rpx;
		box-shadow: 0rpx 13rpx 35rpx 0rpx rgba(60, 90, 214, 0.42);
	}

	.section-0 {

		width: 100%;
		background-color: #3a5df5;

		.section-body {
			padding-top: 50rpx;

			.item {
				margin-bottom: 65rpx;
				width: 100%;
				padding-bottom: 10rpx;
				background-color: #ffffff;
				border-radius: 35rpx;
				box-shadow: 0 0 20rpx 10rpx rgba(#bcbcb5, 0.17);
				margin-bottom: 28rpx;

				.title {
					width: 533rpx;
					height: 50rpx;
					padding-top: 15rpx;
					line-height: 50rpx;
					border-bottom: solid 3rpx #f2f2f0;
					font-size: 26rpx;
					font-weight: normal;
					font-stretch: normal;
					letter-spacing: 0rpx;
					color: #8497ac;
					margin-left: 35rpx;
				}

				.textarea {
					width: 100%;
					height: 300rpx;
					line-height: 30rpx;

					.textarea-body {
						box-sizing: border-box;
						width: 100%;
						height: 300rpx;
						border: none;
						padding: 28rpx 35rpx !important;
						font-weight: normal;
						font-stretch: normal;
						letter-spacing: 0rpx;

						/deep/ .u-textarea__field {
							height: auto !important;
							font-size: 25rpx;
						}
					}

					/deep/ .u-textarea--disabled {
						background-color: #fff;
					}

					.textarea-placeholder {
						font-size: 25rpx;
						font-weight: normal;
						font-stretch: normal;
						line-height: 50rpx;
						letter-spacing: 3rpx;
						color: rgba(0, 0, 0, 0.5);
					}
				}

				.name {
					box-sizing: border-box;
					padding: 0 35rpx;
					width: 100%;
					@include clear();

					.name-text {
						width: 520rpx;
						height: 80rpx;
						line-height: 80rpx;
						font-size: 26rpx;
						font-weight: normal;
						font-stretch: normal;
						letter-spacing: 0rpx;
						color: #46464a;
						float: left;
						text-overflow: ellipsis;
						overflow: hidden;
						font-weight: bold;
						white-space: nowrap;
					}

					.name-text__file {
						color: #0535d6;
					}

					.action {
						width: calc(100% - 520rpx);
						text-align: right;
						float: left;
						height: 80rpx;

						.check {
							box-sizing: border-box;
							border-radius: 50%;
							float: right;
							width: 50rpx;
							height: 50rpx;
							border: solid 3rpx #d1d1d1;
							text-align: center;
							line-height: 48rpx;
							font-size: 26rpx;
							color: #000;
							margin-top: 20rpx;
							transition: 0.3s ease;

							.iconfont {
								color: #1d33c6;
								font-size: 30rpx;
								opacity: 0;
								transition: 0.3s ease;
							}
						}

						.check__active {
							border-color: #ffde00;
							background-color: #ffde00;

							.iconfont {
								opacity: 1;
							}
						}
					}

				}
			}

			box-sizing: border-box;
			width: 100%;
			padding-left: 40rpx;
			padding-right: 40rpx;
			padding-bottom: 50rpx;
			background-color: #fff;
			background-size: cover;
			background-repeat: no-repeat;
			border-top-left-radius: 50rpx;
			border-top-right-radius: 50rpx;
		}

	}
</style>
